import Axios from "./axios"

export function login(username, password) {
    return Axios({
        url: "/api/user/login/",
        method: "post",
        headers: {
            'Content-Type': 'application/json'
        },
        data: {
            username: username,
            password: password
        }
    })
}

export function userregister(username, password, usertype) {
    return Axios({
        url: "/api/user/register/",
        method: "post",
        headers: {
            'Content-Type': 'application/json'
        },
        data: {
            username: username,
            password: password,
            usertype: usertype
        }
    })
}

export function getItemList(username, usertype) {
    return Axios({
        url: "/api/user/list/",
        method: "get",
        // headers: {
        // 	'Content-Type':'application/json'
        // },
        params: {
            username: username,
            usertype: usertype
        }

    })
}

export function getdetail() {
    return Axios({
        url: "/api/user/detail/",
        method: "get",
    })
}

export function GetProjectList(
    projectname,
    testrunner,
    page,
    page_size
) {
    return Axios({
        url: "/api/project/",
        method: "get",
        params: {
            projectname: projectname,
            testrunner: testrunner,
            page: page,
            page_size: page_size,
        }
    })
}

export function AddProjectList(projectname, describe, testrunner) {
    return Axios({
        url: "/api/project/",
        method: "post",
        headers: {
            'Content-Type': 'application/json'
        },
        data: {
            projectname: projectname,
            describe: describe,
            testrunner: testrunner
        }
    })
}

export function editProject(projectid, projectname, describe, testrunner) {
    return Axios({
        url: `/api/project/${projectid}/`,
        method: "put",
        headers: {
            'Content-Type': 'application/json'
        },
        data: {
            projectname: projectname,
            describe: describe,
            testrunner: testrunner
        }
    })
}

export function Projectdetail(projectid) {
    return Axios({
        url: `/api/project/${projectid}/`,
        method: "get",
        // headers: {
        //     'Content-Type':'application/json'
        //     },

    })
}

export function delProject(projectid) {
    return Axios({
        url: `/api/project/${projectid}/`,
        method: "delete",
        // headers: {
        //     'Content-Type':'application/json'
        //     },

    })
}

export function logout() {
    return Axios({
        url: "/api/user/logout/",
        method: "post",
    })
}